#include"RBTree.h"
#include<vector>
#include"AVLTree.h"



void TestRBAVLTree()
{
	const int N = 10000000;
	vector<int> v;
	v.reserve(N);
	srand(time(0));

	for (size_t i = 0; i < N; i++)
	{
		v.push_back(i);
		//v.push_back(rand() + i);
	}

	size_t begin2 = clock();
	RBTree<int, int> rbt;
	for (auto e : v)
	{
		rbt.Insert(make_pair(e, e));
	}
	size_t end2 = clock();

	cout << "RB Insert:" << end2 - begin2 << endl;

	size_t begin3 = clock();
	AVLTree<int, int> avlt;

	for (auto e : v)
	{
		avlt.Insert(make_pair(e, e));
	}
	size_t end3 = clock();
	cout << "AVL Insert:" << end3 - begin3 << endl;

	cout << "RB Height:" << rbt.Height() << endl;
	cout << "AVL Height:" << avlt.Height() << endl;
	cout << "RB 旋转次数:" << rbt._rotateNum << endl;
	cout << "AVL 旋转次数:" << avlt._rotateNum << endl;

	cout << "Size:" << rbt.Size() << endl;

	size_t begin1 = clock();

	// 确定在的值
	/*for (auto e : v)
	{
		rbt.Find(e);
	}*/

	// 随机值
	for (size_t i = 0; i < N; i++)
	{
		rbt.Find((rand() + i));
	}

	size_t end1 = clock();

	cout << "RB Find:" << end1 - begin1 << endl;

	size_t begin4 = clock();

	// 确定在的值
	for (auto e : v)
	{
		avlt.Find(e);
	}

	// 随机值
	/*for (size_t i = 0; i < N; i++)
	{
		avlt.Find((rand() + i));
	}*/

	size_t end4 = clock();

	cout << "AVL Find:" << end4 - begin4 << endl;
}

int main()
{
	TestRBAVLTree();
	return 0;
}